import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

public class JedisConnectionFactory {
    private  static JedisPool jedisPool = null;

    static{
        JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
        jedisPoolConfig.setMaxTotal(8);
        jedisPoolConfig.setMinIdle(0);
        jedisPoolConfig.setMaxIdle(8);
        jedisPoolConfig.setMaxWaitMillis(1000);
        jedisPool = new JedisPool(jedisPoolConfig,"127.0.0.1",8888,1000);
    }

    public static Jedis getJedis(){
       return jedisPool.getResource();
    }

    public static void main(String[] args) {
        Jedis jedis = JedisConnectionFactory.getJedis();
    }
}
